package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.OrderService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * @author hql
 * @date 2019-12-08 16:53
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Reference
    private OrderService orderService;
    @RequestMapping("/addMember")
    public Result addMember(@RequestBody Map<String,String> map){
        Result result =null;
        try {
             result = orderService.addMember(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.TellMember);
        }
       return result;
    }

    /**
     * 根据id查询预约的套餐
     * @param id
     * @return
     */
    @RequestMapping("/findById")
    public Result findById(Integer id){
        Map<String,String> map =null;
        try {
            map = orderService.findById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_MEMBER_NUMBER_REPORT_FAIL);
        }
            return new Result(true,MessageConstant.ORDERSETTING_SUCCESS,map);

    }
}
